/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package com.ruoyi.common.mybatisplus;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mybatis-plus配置
 *
 * @author Mark sunlightcs@gmail.com
 */
@Configuration
public class MybatisPlusConfig {

    private String symEqual="eq_";
    private String symNotEqual="ne_";
    private String symLessThan="lt_";
    private String symLessOrEqualThan="le_";
    private String symGreaterThan="gt_";
    private String symGreaterOrEqualThan="ge_";
    private String symIn="in_";
    private String symNotIn="ni_";
    private String symLike="lk_";
    private String symNotLike="nlk_";
    private String symLeftLike="llk_";
    private String symRightLike="rlk_";
    private String symIsNull="null_";
    private String symIsNotNull="nnull_";
    private String symGroupBy="grp_";
    private String symHaving="having_";
    private String symOrderByAscending="asc_";
    private String symOrderByDescending="desc_";

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {

        WhereCondition.SYM_EQUAL = symEqual;
        WhereCondition.SYM_NOT_EQUAL = symNotEqual;
        WhereCondition.SYM_LESS_THAN = symLessThan;
        WhereCondition.SYM_LESS_OR_EQUAL_THAN = symLessOrEqualThan;
        WhereCondition.SYM_GREATER_THAN = symGreaterThan;
        WhereCondition.SYM_GREATER_OR_EQUALTHAN = symGreaterOrEqualThan;
        WhereCondition.SYM_IN = symIn;
        WhereCondition.SYM_NOT_IN = symNotIn;
        WhereCondition.SYM_LIKE = symLike;
        WhereCondition.SYM_NOT_LIKE = symNotLike;
        WhereCondition.SYM_LEFT_LIKE = symLeftLike;
        WhereCondition.SYM_RIGHT_LIKE = symRightLike;
        WhereCondition.SYM_IS_NULL = symIsNull;
        WhereCondition.SYM_IS_NOT_NULL = symIsNotNull;
        WhereCondition.SYM_GROUP_BY = symGroupBy;
        WhereCondition.SYM_HAVING = symHaving;
        WhereCondition.SYM_ORDER_BY_ASCENDING = symOrderByAscending;
        WhereCondition.SYM_ORDER_BY_DESCENDING = symOrderByDescending;


        return new PaginationInterceptor();
    }

    @Bean
    public MyMetaObjectHandler myMetaObjectHandler(){
        return new MyMetaObjectHandler();
    }

}
